package codename.carrot.bomberman.network;


/**
 *  An abstract class representing a connection to a client or a server.
 * @author Group A4
 *
 */
public abstract class ConnectionThread extends Thread{
	/**
	 * String for debugging.
	 */
	protected final String DEBUG = this.getClass().getSimpleName();
	/**
	 * Status of the connection.
	 */
	protected boolean connected = false;
	/**
	 * The connection message handler.
	 */
	protected MessageHandler messageHandler;
	/**
	 * The ID of the connection.
	 */
	protected int clientID;
	
	/**
	 * For sending an object to the client over the network.
	 * @param object The object to be sent.
	 * @return True if sending the object was a success.
	 */
	public abstract boolean send(Object object);
	
	/**
	 * Terminate the connection.
	 */
	public abstract void terminate();
	
	/**
	 * The thread run method used for fetching objects from the network stream.
	 */
	public abstract void run();
	
	/**
	 * The ID of this connection.
	 * @return The ID of this connection.
	 */
	public int getClientID() {
		return clientID;
	}
}
